<template>
    <div class="cate">
        <van-tabs @click="tabClick">
            <van-tab v-for="item in cates" :key="item.id" :title="item.catename" :name="item.id"></van-tab>
        </van-tabs>
    </div>
</template>

<script>
import {reqHomeCate} from "../../../http/api"
export default {
    data () {
        return {
            //1.初始化
            cates:[],
        }
    },
    mounted () {
        //2.获取分类的数据
        reqHomeCate().then((res)=>{
            this.cates = res.data.list//赋值
        })
    },
    methods: {
        tabClick(e){
            this.$router.push("/list?id="+e+"&type=1")
        }
    }
}
</script>

<style scoped lang="less">
@import url(../../../less/index.less);
.van-tab span{
    font-size: 1rem;
}

</style>